﻿/*
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2009
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions 
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
' DEALINGS IN THE SOFTWARE.
*/

using System;
using MbUnit.Framework;
using WatiN.Core;
using DotNetNuke.Tests.UI.WatiN.Common;
using Gallio.Framework;
using DotNetNuke.Tests.UI.WatiN.Utilities;
using System.Configuration;
using WatiN.Core.DialogHandlers;
using DotNetNuke.Tests.UI.WatiN.Common.WatiNObjects;
using System.IO;
using System.Reflection;




namespace DotNetNuke.Tests.UI.WatiN.HostTests
{
    [TestFixture]
    
    public class HostModuleDefinitionTests : HTBase
    {
        #region Test Setup and TearDown

        [SetUp]
        public void SetUp()
        {
            
            SetUpTest();
        }

        [TearDown]
        public void TearDown()
        {
            TearDownTest();
        }

        #endregion

        #region Tests

        [Test]
        public void Verify_Module_Definition_Page_Loads()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);

            //Act
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");
            
            //Assert
            Assert.IsTrue(actionMenu.ModuleActionMenuImage.Exists);
            Assert.IsTrue(moduleDefinition.InstallModuleLink.Exists);
            Assert.IsTrue(moduleDefinition.CreateNewModuleLink.Exists);
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(moduleDefinition.ModuleTitleSpan.InnerHtml.Contains("Module Definitions"));
        }

        [Test]
        public void Add_New_Module_Via_Action_Menu()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Act
            //actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            actionMenu.InstallModuleActionMenuItem.Click();

            //Assert
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(moduleDefinition.ModuleTitleSpan.InnerHtml.Contains("Install Extension"));
            Assert.IsTrue(moduleDefinition.WizardNextButton.Exists);

            //Act
            ExtensionsPage extensionPage = new ExtensionsPage(homePage);
            extensionPage.UploadExtensionsPackage(ForumPackagePath);
            extensionPage.WizardStartLink.Click();
            extensionPage.WizardNextLink.Click();
            extensionPage.WizardNextLink.Click();
            extensionPage.AcceptLicenseCheckBox.Checked = true;
            extensionPage.WizardNextLink.Click();
            extensionPage.WizardFinishLink.Click();

            //Assert
            Assert.IsTrue(moduleDefinition.ModuleTable.InnerHtml.Contains("Forum"));
            Assert.IsTrue(moduleDefinition.GetModuleRow("Forum").Exists);
        }

        [Test]
        public void Edit_Module()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            string moduleName;
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Act
            if (VersionType.CompareTo("Community") == 0) moduleName = "HTML";

            else moduleName = "HTML Pro";

            moduleDefinition.GetModuleEditButton(moduleName).ClickNoWait();

            //Assert
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(moduleDefinition.ModuleTitleSpan.InnerHtml.Contains("Edit Extension"));
            Assert.IsTrue(moduleDefinition.EditExtensionTitle.InnerHtml.Contains("Configure " + moduleName + " Extension Settings"));

            moduleDefinition.CancelLink.Click();
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(moduleDefinition.ModuleTitleSpan.InnerHtml.Contains("Module Definitions"));
        }

        [Test]
        public void Verify_In_Use_Declaration()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            string moduleName;
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            if (VersionType.CompareTo("Community") == 0)   moduleName = "HTML";

            else moduleName = "HTML Pro";

            //Act
            TableRow moduleRow =  moduleDefinition.GetModuleRow(moduleName);
            TableCell linkCell = moduleRow.TableCells[5];
            Assert.IsTrue(linkCell.InnerHtml.Contains("Yes"));
            linkCell.Link(Find.Any).Click();

            //Assert
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(moduleDefinition.ModuleTitleSpan.InnerHtml.Contains("Module Usage Information"));
            Assert.IsTrue(moduleDefinition.UsageDetailsDiv.InnerHtml.Contains("Usage Information for " + moduleName));

            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Act
            moduleRow = moduleDefinition.GetModuleRow("Authentication");
            linkCell = moduleRow.TableCells[5];

            //Assert
            Assert.IsFalse(linkCell.Link(Find.Any).Exists);
            Assert.IsTrue(linkCell.InnerHtml.Contains("No"));
        }

        [Test]
        public void Verify_Module_Can_Be_Deleted()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ExtensionsPage extensionsPage = new ExtensionsPage(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Add A module that can be removed
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            actionMenu.InstallModuleActionMenuItem.ClickNoWait();
            System.Threading.Thread.Sleep(2500);
            ExtensionsPage extensionPage = new ExtensionsPage(homePage);
            extensionsPage.InstallExtension(ForumPackagePath);

            //Act
            moduleDefinition.GetModuleDeleteButton("Forum").ClickNoWait();

            //Assert
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(moduleDefinition.ModuleTitleSpan.InnerHtml.Contains("UnInstall Package"));
            Assert.AreEqual("Forum", moduleDefinition.UninstallPackageFriendlyNameSpan.Text);
    
            //Act
            ConfirmDialogHandler dialog = new ConfirmDialogHandler();
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");

            using (new UseDialogOnce(ieInstance.DialogWatcher, dialog))
            {
                extensionsPage.UninstallPackageLink.ClickNoWait();
                dialog.WaitUntilExists();
                dialog.OKButton.Click();
            }
           
            ieInstance.WaitForComplete();

            //Assert
            Assert.IsTrue(extensionsPage.UnInstallResultsDiv.InnerHtml.Contains("Package Uninstall Successful"));
            extensionsPage.UnInstallReturnLink.Click();
            Assert.IsFalse(moduleDefinition.ModuleTable.InnerHtml.Contains("Forum"));

        }

        [Test]
        public void Verify_Action_Menu_Items()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Act
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");

            //Assert
            Assert.IsTrue(actionMenu.CreateNewModuleActionMenuItem.Exists);
            Assert.IsTrue(actionMenu.InstallModuleActionMenuItem.Exists);
            Assert.IsTrue(actionMenu.DeleteActionMenuItem.Exists);
            Assert.IsTrue(actionMenu.HelpActionMenuItem.Exists);
            Assert.IsTrue(actionMenu.ModuleActionMenuImage.Exists);
            Assert.IsTrue(actionMenu.MoveActionMenuItem.Exists);
            Assert.IsTrue(actionMenu.OnlineHelpActionMenuItem.Exists);
            Assert.IsTrue(actionMenu.PrintActionMenuItem.Exists);
            Assert.IsTrue(actionMenu.RefreshActionMenuItem.Exists);
            Assert.IsTrue(actionMenu.SettingsActionMenuItem.Exists);
            Assert.IsTrue(actionMenu.ViewSourceActionMenuItem.Exists);
        }

        [Test]
        public void Create_New_Module_Via_Action_Menu()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Act
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            actionMenu.CreateNewModuleActionMenuItem.Click();
            CreateNewModulePage createModulePage = new CreateNewModulePage(homePage);

            //Assert
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(moduleDefinition.ModuleTitleSpan.InnerHtml.Contains("Create New Module"));
            Assert.IsTrue(createModulePage.CreateModuleFromSelectList.Options[0].Text.Contains("<None Specified>"));
            Assert.IsTrue(createModulePage.CreateModuleFromSelectList.Options[1].Text.Contains("New"));
            Assert.IsTrue(createModulePage.CreateModuleFromSelectList.Options[2].Text.Contains("Control"));
            Assert.IsTrue(createModulePage.CreateModuleFromSelectList.Options[3].Text.Contains("Manifest"));
        }

        [Test]
        public void Verify_Online_Help_Action_Item()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Act
            System.Threading.Thread.Sleep(1500);
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            actionMenu.OnlineHelpActionMenuItem.ClickNoWait();
            System.Threading.Thread.Sleep(1500);

            //Assert
            IE popUpWindow = IE.AttachTo<IE>(Find.ByUrl(s => s.EndsWith("&helpmodule=Extensions")));
            Assert.IsTrue(popUpWindow.Title.Contains("DotNetNuke"));
            popUpWindow.Close();
        }

        [Test]
        public void Verify_Help_Action_Item()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Act
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            actionMenu.HelpActionMenuItem.Click();
            
            //Assert
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(moduleDefinition.ModuleTitleSpan.InnerHtml.Contains("Module Help"));
            Assert.IsTrue(moduleDefinition.ModuleHelpInfoSpan.InnerHtml.Contains("DotNetNuke.Extensions"));
        }

        [Test]
        public void Verify_Print_Action_Item()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Act
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            actionMenu.PrintActionMenuItem.ClickNoWait();
            System.Threading.Thread.Sleep(4000);

            //Assert
            IE popUpWindow = IE.AttachTo<IE>(Find.ByUrl(s => s.Contains("/dnnprintmode/true")));
            Assert.IsTrue(popUpWindow.Title.Contains("Module Definitions"));
            popUpWindow.Close();
        }

        [Test]
        public void Verify_View_Source_Action_Item()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Act
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            actionMenu.ViewSourceActionMenuItem.Click();

            //Assert
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(moduleDefinition.ModuleTitleSpan.InnerHtml.Contains("View Module Control Source"));
        }

        [Test]
        public void Verify_Settings_Action_Item()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Act
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            actionMenu.SettingsActionMenuItem.Click();

            //Assert
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(moduleDefinition.ModuleTitleSpan.InnerHtml.Equals("Module"));
            Assert.IsTrue(moduleDefinition.ModuleTitleField.Value.Equals("Module Definitions"));
        }

        [Test]
        public void Verify_Delete_Action_Item()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");
            ConfirmDialogHandler dialog = new ConfirmDialogHandler();

            //Act
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");

            using (new UseDialogOnce(ieInstance.DialogWatcher, dialog))
            {
                actionMenu.DeleteActionMenuItem.ClickNoWait();
                dialog.WaitUntilExists();
                dialog.CancelButton.Click();
            }

            //Assert
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(moduleDefinition.ModuleTitleSpan.InnerHtml.Contains("Module Definitions"));

            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            using (new UseDialogOnce(ieInstance.DialogWatcher, dialog))
            {
                actionMenu.DeleteActionMenuItem.ClickNoWait();
                dialog.WaitUntilExists();
                dialog.OKButton.Click();
            }

            //Assert
            Assert.IsFalse(homePage.ContentDiv.InnerHtml.Contains("Module Definitions"));
            
        }
        [Test]
        public void Verify_Refresh_Action_Item()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Act
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            actionMenu.RefreshActionMenuItem.ClickNoWait();
            System.Threading.Thread.Sleep(3500);

            //Assert
            Assert.IsTrue(actionMenu.ModuleActionMenuImage.Exists);
            Assert.IsTrue(moduleDefinition.InstallModuleLink.Exists);
            Assert.IsTrue(moduleDefinition.CreateNewModuleLink.Exists);
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(moduleDefinition.ModuleTitleSpan.InnerHtml.Contains("Module Definitions"));
        }

        [Test]
        public void Verify_Move_Action_Item_Single_Module()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");

            //Act
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Module Definitions"));
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            actionMenu.MoveActionMenuItem.FireEvent("onmouseover");
            actionMenu.MoveLeftPaneLink.Click();

            //Assert
            Assert.IsTrue(homePage.LeftPaneCell.InnerHtml.Contains("Module Definitions"));

            //Act
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            actionMenu.MoveActionMenuItem.FireEvent("onmouseover");
            actionMenu.MoveRightPaneLink.Click();

            //Assert
            Assert.IsTrue(homePage.RightPaneCell.InnerHtml.Contains("Module Definitions"));

            //Act
            actionMenu.ModuleActionMenuImage.FireEvent("onmouseover");
            actionMenu.MoveActionMenuItem.FireEvent("onmouseover");
            actionMenu.MoveBottomPaneLink.Click();

            //Assert
            Assert.IsTrue(homePage.BottomPaneDiv.InnerHtml.Contains("Module Definitions"));
        }

        [Test]
        public void Verify_Move_Action_Item_Multiple_Modules()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            ModuleDefinitionPage moduleDefinition = new ModuleDefinitionPage(homePage);
            ModuleActionMenu actionMenu = new ModuleActionMenu(homePage);
            ieInstance.GoTo(SiteURL + "/tabid/18/portalid/0/Default.aspx");
            bool usesRibbonBar = false;
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
            }
            string moduleName;

            //Add two modules for testing 
            for (int i = 0; i < 2; i++)
            {

                moduleName = "Test Module " + i;
                if (!usesRibbonBar)
                {
                    if (VersionType.CompareTo("Community") == 0)
                    {
                        controlPanel.AddModuleToPage(moduleName, "HTML");
                    }
                    else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                    {
                        controlPanel.AddModuleToPage(moduleName, "HTML Pro");
                    }
                }
                else
                {
                    if (VersionType.CompareTo("Community") == 0)
                    {
                        ribbonBar.AddHTMLModuleToPage(moduleName, "HTML");

                    }
                    else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                    {
                        ribbonBar.AddHTMLModuleToPage(moduleName, "HTML Pro");

                    }
                }
                System.Threading.Thread.Sleep(1000);
            }
            Assert.IsTrue(homePage.GetAllModuleContainers()[0].InnerHtml.Contains("Module Definitions"));
            Assert.IsTrue(homePage.GetAllModuleContainers()[1].InnerHtml.Contains("Test Module 0"));
            Assert.IsTrue(homePage.GetAllModuleContainers()[2].InnerHtml.Contains("Test Module 1"));

            //Move Module within a pane
            //Act
            actionMenu.GetActionMenuImageForModule(0).FireEvent("onmouseover");
            actionMenu.GetMoveActionMenuSpanForPaneAndModuleNumber("Content", 0).FireEvent("onmouseover");
            actionMenu.MoveModuleBottomLink.Click();

            //Assert
            Assert.IsTrue(homePage.GetAllModuleContainers()[2].InnerHtml.Contains("Module Definitions"));
            Assert.IsTrue(homePage.GetAllModuleContainers()[0].InnerHtml.Contains("Test Module 0"));
            Assert.IsTrue(homePage.GetAllModuleContainers()[1].InnerHtml.Contains("Test Module 1"));

            //Act
            actionMenu.GetActionMenuImageForModule(2).FireEvent("onmouseover");
            actionMenu.GetMoveActionMenuSpanForPaneAndModuleNumber("Content", 2).FireEvent("onmouseover");
            actionMenu.MoveModuleUpLink.Click();

            //Assert
            Assert.IsTrue(homePage.GetAllModuleContainers()[1].InnerHtml.Contains("Module Definitions"));
            Assert.IsTrue(homePage.GetAllModuleContainers()[0].InnerHtml.Contains("Test Module 0"));
            Assert.IsTrue(homePage.GetAllModuleContainers()[2].InnerHtml.Contains("Test Module 1"));

            //Act
            actionMenu.GetActionMenuImageForModule(1).FireEvent("onmouseover");
            actionMenu.GetMoveActionMenuSpanForPaneAndModuleNumber("Content", 1).FireEvent("onmouseover");
            actionMenu.MoveModuleDownLink.Click();

            //Assert
            Assert.IsTrue(homePage.GetAllModuleContainers()[2].InnerHtml.Contains("Module Definitions"));
            Assert.IsTrue(homePage.GetAllModuleContainers()[0].InnerHtml.Contains("Test Module 0"));
            Assert.IsTrue(homePage.GetAllModuleContainers()[1].InnerHtml.Contains("Test Module 1"));

            //Act
            actionMenu.GetActionMenuImageForModule(2).FireEvent("onmouseover");
            actionMenu.GetMoveActionMenuSpanForPaneAndModuleNumber("Content", 2).FireEvent("onmouseover");
            actionMenu.MoveModuleTopLink.Click();

            //Assert
            Assert.IsTrue(homePage.GetAllModuleContainers()[0].InnerHtml.Contains("Module Definitions"));
            Assert.IsTrue(homePage.GetAllModuleContainers()[1].InnerHtml.Contains("Test Module 0"));
            Assert.IsTrue(homePage.GetAllModuleContainers()[2].InnerHtml.Contains("Test Module 1"));

            
            //Move Module between panes.
            //Act
            actionMenu.GetActionMenuImageForModule(0).FireEvent("onmouseover");
            actionMenu.GetMoveActionMenuSpanForPane("Content").FireEvent("onmouseover");
            actionMenu.MoveLeftPaneLink.Click();

            //Assert
            Assert.IsTrue(homePage.LeftPaneCell.InnerHtml.Contains("Module Definitions"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Test Module 0"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Test Module 1"));

            //Act
            actionMenu.GetActionMenuImageForModule(0).FireEvent("onmouseover");
            actionMenu.GetMoveActionMenuSpanForPane("Left").FireEvent("onmouseover");
            actionMenu.MoveRightPaneLink.Click();

            //Assert
            Assert.IsTrue(homePage.RightPaneCell.InnerHtml.Contains("Module Definitions"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Test Module 0"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Test Module 1"));

            //Act
            actionMenu.GetActionMenuImageForModule(2).FireEvent("onmouseover");
            actionMenu.GetMoveActionMenuSpanForPane("Right").FireEvent("onmouseover");
            actionMenu.MoveBottomPaneLink.Click();

            //Assert
            Assert.IsTrue(homePage.BottomPaneDiv.InnerHtml.Contains("Module Definitions"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Test Module 0"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Test Module 1"));

        }

        #endregion
    }
}
